home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Devices and Hardware / Display Manager / DMFkey Source / DMFkey.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.1 KB  |  91 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        DMFkey.c
  3.     
  4.     Description:Uses the Display Manager 2.0 (found in System 7.5.2 and later, or in
  5.                 the version 2.0 Display Enabler system extension which ships with
  6.                 AppleVision multisync displays) to change the monitor screen resolution
  7.                 the specified HxV resolutions.
  8.                 
  9.                 This FKey will flip between 640x480 and BIG.
  10.                 BIG is up to 2000x2000 if your monitor supports it.
  11.                 
  12.                 For information on the use of the RequestVideo sample code, please 
  13.                 refer to the    documentation found in the Display Manager Development
  14.                 Kit, or just look at the code and comments to figure it out.
  15.  
  16.     Author:        EWA
  17.  
  18.     Copyright:     Copyright: © 1996-1999 by Apple Computer, Inc.
  19.                 all rights reserved.
  20.     
  21.     Disclaimer:    You may incorporate this sample code into your applications without
  22.                 restriction, though the sample code has been provided "AS IS" and the
  23.                 responsibility for its operation is 100% yours.  However, what you are
  24.                 not permitted to do is to redistribute the source as "DSC Sample Code"
  25.                 after having made changes. If you're going to re-distribute the source,
  26.                 we require that you make it clear in the source that the code was
  27.                 descended from Apple Sample Code, but that you've made changes.
  28.     
  29.     Change History (most recent first):
  30.                 6/24/99    Updated for Metrowerks Codewarror Pro 2.1(KG)
  31.                 2/10/96    New today(EWA)
  32.  
  33. */
  34.  
  35. #define minHorizontalRequest        640
  36. #define minVerticalRequest            480
  37.  
  38. #define maxHorizontalRequest        1600
  39. #define maxVerticalRequest            1200
  40.  
  41. #define bitDepthRequest                32
  42.  
  43. #include <Types.h>
  44. #include <Quickdraw.h>
  45. #include <OSUtils.h>
  46.  
  47. #include "RequestVideo.h"                    // The code that does the real work
  48.  
  49. struct INITGlobals {
  50.     QDGlobals        initQDGlobals;            // FKEY's own private QDGlobals
  51.     unsigned long    initQDBase;                // FKEY's global base
  52. };
  53. typedef struct INITGlobals INITGlobals;
  54.  
  55. main()
  56. {
  57.     VideoRequestRec    requestRec;
  58.     INITGlobals        qdGlobs;
  59.     long            oldA5;
  60.     unsigned long    theHorizontalRequest;
  61.     unsigned long    theVerticalRequest;        
  62.     
  63.     oldA5 = SetA5((long) &qdGlobs.initQDBase);
  64.     InitGraf((Ptr) &qdGlobs.initQDGlobals.thePort);
  65.     
  66.     theHorizontalRequest = minHorizontalRequest;
  67.     theVerticalRequest = minVerticalRequest;
  68.  
  69.     requestRec.screenDevice = GetMainDevice ();
  70.     requestRec.reqHorizontal = (*(*(requestRec.screenDevice))->gdPMap)->bounds.right;    // main screen is always zero offset (bounds.left == 0)
  71.     requestRec.reqVertical = (*(*(requestRec.screenDevice))->gdPMap)->bounds.bottom;    // main screen is always zero offset (bounds.top == 0)
  72.      if (requestRec.reqHorizontal == minHorizontalRequest || requestRec.reqVertical == minVerticalRequest)    // on a small screen now?
  73.      {
  74.          theHorizontalRequest    =    maxHorizontalRequest;
  75.          theVerticalRequest        =    maxVerticalRequest;
  76.      }
  77.  
  78.     requestRec.reqBitDepth        =    bitDepthRequest;        // bit depth request
  79.     requestRec.reqHorizontal    =    theHorizontalRequest;    // H request
  80.     requestRec.reqVertical        =    theVerticalRequest;        // V request
  81.     requestRec.displayMode        =    nil;                    // must init to nil
  82.     requestRec.depthMode        =    nil;                    // must init to nil
  83.     requestRec.requestFlags        =    0;                        
  84.     if (noErr == RVRequestVideoSetting(&requestRec))
  85.     {
  86.         RVSetVideoRequest (&requestRec);
  87.     }
  88.     SetA5(oldA5);
  89.     return (noErr);
  90. }
  91.